// 这就是menu的独立模块
import { menuList } from "../../../request/api";
//state
const state = {
  menulist: [],
};

//getters
const getters = {
  getMenu(state) {
    return state.menulist;
  },
};

//mutations
const mutations = {
  REQ_MENULIST(state, payload) {
    state.menulist = payload;
  },
};

//actions
const actions = {
  //封装一个获取列表的行动
  getMenuListAction({ commit }) {
    //调用接口
  menuList({istree:1}).then((res) => {
      if (res.code == 200) {
        console.log(res,'-------------------');
        commit("REQ_MENULIST", res.list);
      }
    });
  },
};

export default {
  state,
  getters,
  mutations,
  actions,
  //开启命名空间
  namespaced: true,
};
